<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title></title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="format-detection" content="telephone=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="alternate icon" type="image/png" href="assets/i/favicon.png">
  <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
  <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
  <style>
    .header {
      text-align: center;
    }
    .header h1 {
      font-size: 200%;
      color: #333;
      margin-top: 30px;
    }
    .header p {
      font-size: 14px;
    }
    span {
      font-size: 120%;
      margin-right: 10px;
      font-weight: bold;
    }
  </style>
</head>
<body>
<div class="header">
  <div class="am-g">
    <h1>试题生成</h1>
    <p>根据考点自动生成题目，欢迎您的使用！</p>
  </div>
  <hr />
</div>
<div class="am-g">
  <div class="am-u-lg-4 am-u-sm-centered">
  
  <form action="question.php" method="post">
    <span>选择题目类型</span>
    <select name="type">
			<option value="填空题">填空题</option>
			<option value="选择题">选择题</option>
			<option value="判断题">判断题</option>
			<option value="简答题">简答题</option>
			<option value="编程题">编程题</option>
	</select>
	<hr>
	<span>选择难度</span>
	<input name="difficulty" type="radio" value="简单" checked="checked"/>简单
	<input name="difficulty" type="radio" value="中等"/>中等
	<input name="difficulty" type="radio" value="困难"/>困难
    <hr>
    
    <span>选择题目考点</span><br>
	<?php
	require_once 'mysql.php';
	$link = connect ();
	$tags = fetchTags ();
	
	for($i = 0; $i < count ( $tags ); $i ++) {
		$str = $tags [$i] ['tag'];
		if ($i == 0 || $i == 1) {
			echo '<input type="checkbox" value="' . $str . '" name="tags[]" checked="checked" />' . $str.'&nbsp&nbsp';
		} else {
			echo '<input type="checkbox" value="' . $str . '" name="tags[]" />' . $str.'&nbsp;&nbsp;';
		}
	}
	
	mysql_close ( $link );
	?>
	<br>
	<button class="am-btn am-btn-success am-btn-xs" id="number">已选择考点数：2</button>
    <hr>
    
	<span>选择题目数量</span>
	<select name="num">
		<option value="2" id="option1">2</option>
		<option value="4" id="option2">4</option>
		<option value="6" id="option3">6</option>
    </select>
    <hr>
    
	<input type="submit" name="" value="生成题目" class="am-btn am-btn-primary am-round am-btn-block">
    </form>
    <br>
    <br>
  </div>
</div>
<hr>

<script type="text/javascript">

	function initOption() {
		var checked = $("input[type='checkbox']:checked").length;
		$("#number").text('已选择考点数：'+checked);
		
	    $("#option1").attr("value", checked);
	    $("#option1").text(checked);
	    
	    $("#option2").attr("value", checked*2);
	    $("#option2").text(checked*2);
	    
	    $("#option3").attr("value", checked*3);
	    $("#option3").text(checked*3);
	}

	$(document).ready(function(){ 
		initOption();
		$("#option1").attr("selected", "selected");
	}); 
	
	$(function(){
	    $("input[type='checkbox']").click(function() {
	    	initOption();
	    });
	})
</script>
</body>
</html>
